10、星际探险

题目 星际探险

image-300603fb

思路分析

以为是贪心 就胡乱写了一通 结果没分

但是无伤大雅 贪心模拟并不难 25分的最后一题万一就蒙对了呢 是吧

//贪心 每次大的回去

#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

typedef long long LL;

const LL mod=1e9+7;

priority_queue<LL> q;

int main()

{

	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int n;cin>>n;

	for(int i=0;i<n;i++){

	    int x;cin>>x;

	    q.push(x);

	}

	LL sum=0;

	while(q.size()>1){

		int	First=q.top();

		q.pop();

		int Second=q.top();

		q.pop();

		sum=(sum+max(LL(pow(First,Second)),LL(pow(Second,First))))%mod;

		q.push(First);

	}

	cout<<sum;

	return 0;

}

正解是最大生成树+数论 写它干嘛呢

代码实现


同类题型

视频讲解


⬅️ 库函数专辑 🏠 00-刷题理模型 ➡️ 1、小蓝的决议